package top.lixunda.common.utils;

import java.util.Collection;
import java.util.Map;

/**
 * @author Xumda
 * @version time:2019/11/20 9:54
 * <p>
 * 验证器，验证各种对象格式
 */
@SuppressWarnings({"WeakerAccess", "unused"})
public class ObjectValidators {

    public static boolean isEmpty(Collection collection) {
        return collection == null || collection.size() <= 0;
    }

    public static boolean isNotEmpty(Collection collection) {
        return !isEmpty(collection);
    }

    public static boolean isEmpty(Map map) {
        return map == null || map.size() <= 0;
    }

    public static boolean isNotEmpty(Map map) {
        return !isEmpty(map);
    }

    public static boolean isEmpty(String str) {
        return str == null || str.length() <= 0;
    }

    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }

    public static boolean isIpAddr(String ip) {
        return isNotEmpty(ip);
    }

    public static boolean isNotIpAddr(String ip) {
        return !isIpAddr(ip);
    }

    public static boolean isEmpty(Object o) {
        return o == null;
    }

    public static boolean isNotEmpty(Object o) {
        return !isEmpty(o);
    }

    public static boolean isEmpty(Object[] o) {
        return o == null || o.length == 0;
    }

    public static boolean isNotEmpty(Object[] o) {
        return !isEmpty(o);
    }

}
